package chapter1;

public class EvenTimesNum {
    public static void  printOddTimesNum1(int[] arr){
        int eor = 0;
        for (int e:arr){
            eor = eor^e;
        }
        System.out.println(eor);
    }
    public static void printOddTimesNum2(int[] arr){
        int eor1 = 0;
        for (int e:arr){
            eor1 = eor1^e;
        }
        int eor = 0;
        int rightOne = eor1 & (~eor1 +1);
        for (int e:arr){
            if ((e & rightOne) ==0){
                eor = eor^e;
            }
        }
        eor1 = eor^eor1;
        System.out.println("a="+eor+",b="+eor1);
    }

    public static void main(String[] args) {
        int[] arr = {4,4,4,4,3,3,2,1,1,4,4,7,7,7};
        printOddTimesNum2(arr);
    }
}
